import Taro, {Component} from '@tarojs/taro'
import {connect} from '@tarojs/redux'
import { View, Image } from '@tarojs/components';
import './index.less'

@connect(({companyProductList, loading}) => ({
  companyProductList,
  loading
}))

export default class GalleryDetail extends Component {

  config = {
    navigationBarTitleText: ''
  }

  constructor(props) {
    super(props)
    this.state = {
      current: 0
    }
  }

  componentWillMount() {
  }

  componentDidMount() {}

  componentWillUnmount() {
  }

  componentDidShow() {
  }

  componentDidHide() {
  }

  // 预览图片
  viewImg(child){
    const {
      companyProductList, dispatch
      } = this.props;
      const {
        files
      } = companyProductList;
      wx.previewImage({
          current: child.topImage,
          urls: files.map(item => item.topImage)
      })
  }

  render() {
    const {
      companyProductList, dispatch
    } = this.props;
    const {
      files
    } = companyProductList;
    return (
      <View className={'galleryDetail'}>
        {
            files.map((item, i) => <View className='child' key={i+'photoList'}>
                <Image src={item.topImage} ontouchend={this.viewImg.bind(this, item)}/>
            </View>)
        }
      </View>
    )
  }
}
